package com.tepth.maintenancesystem.presenter;

import android.content.Context;

import com.superrecycleview.superlibrary.adapter.BaseViewHolder;
import com.superrecycleview.superlibrary.adapter.SuperBaseAdapter;
import com.tepth.maintenancesystem.R;
import com.tepth.maintenancesystem.bean.AlarmObj;
import com.tepth.maintenancesystem.bean.VehicleObj;

import java.util.List;

/**
 * Created by LHQ on 2016/11/28.
 */

public class MyAlarmAdapter extends SuperBaseAdapter<AlarmObj> {

    public MyAlarmAdapter(Context context, List<AlarmObj> data){
        super(context,data);
    }
    @Override
    protected void convert(BaseViewHolder holder, AlarmObj item, int position) {
        holder.setText(R.id.alarm_number,item.getNumber());
        holder.setText(R.id.alarm_name,item.getName());
        holder.setText(R.id.alarm_time,item.getTime());
        if(item.getLevel()=="1"){
            holder.setBackgroundResource(R.id.alarm_number,R.drawable.warning_red);
        }else if(item.getLevel()=="2"){
            holder.setBackgroundResource(R.id.alarm_number,R.drawable.warning_orange);
        }else{
            holder.setBackgroundResource(R.id.alarm_number,R.drawable.warning_yellow);
        }
        if(item.getState()=="1"){
            holder.setBackgroundResource(R.id.alarm_state_img,R.drawable.alarm_untreated_icon);
        }else{
            holder.setBackgroundResource(R.id.alarm_state_img,R.drawable.alarm_completed_icon);
        }
    }

    @Override
    protected int getItemViewLayoutId(int position, AlarmObj item) {
        return R.layout.alarm_item;
    }

}
